Automatic white balance based on surface reflection decomposition

ABSTRACT

An automatic white balance (AWB) method is performed on an image to adjust color gains of the image. The image is pre-processed into a set of pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value. For each candidate illuminant in a set of candidate illuminants, an indicator value that has a diffuse component and a specular component is calculated. One of the candidate illuminants is identified as a resulting illuminant, for which the indicator value is the minimum indicator value among the candidate illuminants. The minimum indicator value corresponds to cancellation of the specular component. The color gains of the image is then adjusted according to color ratios derived from the resulting illuminant.

TECHNICAL FIELD

Embodiments of the invention relate to the fields of color photography, digital cameras, color printing, and digital color image processing.

BACKGROUND

All consumer color display devices are calibrated so that when the values of color channels Red (R)=Green (G)=Blue (B), the color is displayed at a standard “white point” chromaticity, mostly D65 or D50 according to the International Commission on Illumination (abbreviated as CIE) standard. Digital color cameras using complementary metal-oxide semiconductor (CMOS) or charge-coupled device (CCD) sensors have different sensitivities for RGB channels, resulting in raw images with some color cast (e.g., greenish). Furthermore, the color of an object varies as a function of the color of the light source (e.g., tungsten light or daylight), and the mutual reflection from ambient objects. Therefore, it is often necessary to adjust the “white point” of a raw image before one can process and display the image in proper color reproduction. This white point adjustment is called white balance (WB), and it is typically performed by applying proper gains to the color channels so that neutral objects (such as black, gray, and white) in the image are rendered with approximately equal R, G, B values. In digital cameras, the white point can be manually or automatically adjusted. Automatic white balance (AWB) is thus an important operation in color imaging applications.

Most conventional AWB algorithms rely on some physical features (such as the color gamut) and statistical properties (such as the average color distribution) of natural scenes. The conventional AWB algorithms, which are sensitive to the statistics of the scene contents, often encounter one or more of the following difficulties: 1) a dominant color biases the results, 2) the estimate has a high probability to be wrong when there is no neutral color in the image, 3) inaccurate camera calibration can cause the scene statistics to be different from the statistics used by the camera, 4) a large set of training samples with ground truth may be required to build up reliable statistics, and 5) the algorithm performance may be affected by unit-to-unit variations in the mass production of cameras. Therefore, it is highly desirable to develop AWB techniques that are more robust and relatively insensitive to scene contents.

SUMMARY

In one embodiment, a method is provided for performing automatic white balance on an image. The method comprises: pre-processing the image to obtain a plurality of pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value; calculating, for each candidate illuminant in a set of candidate illuminants, an indicator value that has a diffuse component and a specular component; identifying one of the candidate illuminants as a resulting illuminant for which the indicator value is a minimum indicator value among the candidate illuminants, wherein the minimum indicator value corresponds to cancellation of the specular component; and adjusting color gains of the image according to color ratios derived from the resulting illuminant.

In another embodiment, a device is provided performing automatic white balance on an image. The device comprises: a memory to store the image; and an image processing pipeline coupled to the memory. The image processing pipeline is operative to: pre-process the image to obtain a plurality of pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value; calculate, for each candidate illuminant in a set of candidate illuminants, an indicator value that has a diffuse component and a specular component; identify one of the candidate illuminants as a resulting illuminant for which the indicator value is a minimum indicator value among the candidate illuminants, wherein the minimum indicator value corresponds to cancellation of the specular component; and adjust color gains of the image according to color ratios derived from the resulting illuminant. The device further comprises a display coupled to the image processing pipeline to display the image with the adjusted color gains.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that different references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at least one. Further, when a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to effect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described.

FIG. 1A illustrates an image processing pipeline for color correction according to one embodiment.

FIG. 1B illustrates a device that includes the image processing pipeline of FIG. 1A according to one embodiment.

FIG. 2 illustrates the projection of two color surfaces on a plane that is perpendicular to a light source vector.

FIG. 3 is a diagram illustrating an automatic white balance module that performs a minimum projected area (MPA) method according to one embodiment.

FIGS. 4A, 4B and 4C illustrate examples of projection results using three different candidate illuminants.

FIG. 5 is a diagram illustrating an automatic white balance module that performs a block MPA method according to one embodiment.

FIG. 6 is a flow diagram illustrating a MPA method according to one embodiment.

FIG. 7 is a block diagram illustrating an automatic white balance module that performs a minimum total variation (MTV) method according to one embodiment.

FIG. 8 is a flow diagram illustrating a MTV method according to one embodiment.

FIG. 9 is a flow diagram illustrating a method for automatic white balance according to one embodiment.

DETAILED DESCRIPTION

In the following description, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In other instances, well-known circuits, structures and techniques have not been shown in detail in order not to obscure the understanding of this description. It will be appreciated, however, by one skilled in the art, that the invention may be practiced without such specific details. Those of ordinary skill in the art, with the included descriptions, will be able to implement appropriate functionality without undue experimentation.

Systems and methods based on surface reflection decomposition are provided for performing automatic white balance (AWB). The systems and methods are robust and relatively insensitive to scene contents when compared with those based on conventional AWB algorithms. The systems and methods do not rely on detailed scene statistics or a large image database for training. In the following, a minimum projected area (MPA) method and a minimum total variation (MTV) method are described, both based on decomposing the surface reflection into a specular component and a diffuse component, and on the cancellation of the specular component.

As used herein, the term “tricolor values,” or equivalently “RGB values” or “RGB channels,” refers to the three color values (red, green, blue) of a color image. The terms “illuminant” and “light source” are used interchangeably. Furthermore, a chroma image refers to a color difference image, which can be computed from taking the difference between one color channel and another color channel, or the difference between linear combinations of color channels.

FIG. 1A illustrates an example of an image processing pipeline 100 that performs color correction according to one embodiment. The image processing pipeline 100 includes an AWB module 110, which receives raw RGB values as input, and outputs white-balance corrected RGB values. The raw RGB values may be generated by an image sensor, a camera, a video recorder, etc. The operations of the AWB module 110 will be explained in detail with reference to FIGS. 2-10. The image processing pipeline 100 further includes a color correction matrix (CCM) module 120, which performs 3×3 matrix operations on the RGB values output from the AWB module 110. The CCM module 120 can reduce the difference between the spectral characteristics of the image sensor and the spectral response of a standardized color device” (e.g., an sRGB color display). The image processing pipeline 100 may further include a gamma correction module 130, which applies a nonlinear function on the RGB values output from the CCM module 120 to compensate the nonlinear luminance effect of display devices. The output of the image processing pipeline 100 is a collection of standard RGB (sRGB) values ready to be displayed.

FIG. 1B illustrates a system in the form of a device 150 that includes the image processing pipeline 100 of FIG. 1A according to one embodiment. In addition to the image processing pipeline 100, the device 150 includes a memory 160 for storing image data or intermediate image data to be processed by the image processing pipeline 100, and a display 140 for displaying an image with sRGB values. It is understood that the device 150 may include additional components, including but not limited to: image sensors, one or more processors, user interface, network interface, etc. In one embodiment, the device 150 may be a digital camera; alternatively, the device 150 may be part of a computing and/or communication device, such as a computer, laptop, smartphone, smart watch, etc.

Before describing the embodiments of the AWB module 110, it is helpful to first explain the principles according to which the AWB module 110 operates.

Let f(θ; λ) be the bidirectional spectral reflectance distribution function (BSRDF), where θ represents all angle-dependent factors and λ the wavelength of light. The BSRDF of most colored object surfaces can be described as a combination of two reflection components, an interface reflection (specular) component and a body reflection (diffuse) component. The interface reflection is often non-selective, i.e., it reflects light of all visible wavelength equally well. This model is called the neutral interface reflection (NIR) model. Based on the NIR model, the BSRDF f(θ; λ) can be expressed as: f(θ;λ)=ρ(λ)h(θ)+ρ_(s) k(θ),  (1) where ρ(λ) is the diffuse reflectance factor, ρ_(s) is the specular reflectance factor, and h(θ) and k(θ) are the angular dependence of the reflectance factors. A key feature of the NIR model is that the spectral factor and the geometrical factor in each reflection component are completely separable.

Assume that L(λ) is the spectral power distribution of the illuminant, and S_(r)(λ), S_(g)(λ), and S_(b)(λ) are the three sensor fundamentals (i.e., spectral responsivity functions). The RGB color space can be derived as:

$\begin{matrix} {\begin{matrix} {R = {\int{{L(\lambda)}{f\left( {\theta;\lambda} \right)}{S_{r}(\lambda)}d\;\lambda}}} \\ {{= {{{h(\theta)}{\int{{L(\lambda)}{\rho(\lambda)}{S_{r}(\lambda)}d\;\lambda}}} + {\rho_{s}{k(\theta)}{\int{{L(\lambda)}{S_{r}(\lambda)}d\;\lambda}}}}},} \end{matrix}{{G = {{{h(\theta)}{\int{{L(\lambda)}{\rho(\lambda)}{S_{g}(\lambda)}d\;\lambda}}} + {\rho_{s}{k(\theta)}{\int{{L(\lambda)}{S_{g}(\lambda)}d\;\lambda}}}}},{B = {{{h(\theta)}{\int{{L(\lambda)}{\rho(\lambda)}{S_{b}(\lambda)}d\;\lambda}}} + {\rho_{s}{k(\theta)}{\int{{L(\lambda)}{S_{b}(\lambda)}d\;{\lambda.{Let}}}}}}}}{{L_{r} = {\int{{L(\lambda)}{S_{r}(\lambda)}d\;\lambda}}},{L_{g} = {\int{{L(\lambda)}{S_{g}(\lambda)}d\;\lambda}}},{L_{b} = {\int{{L(\lambda)}{S_{b}(\lambda)}d\;\lambda}}},{\rho_{r} = \frac{\int{{L(\lambda)}{\rho(\lambda)}{S_{r}(\lambda)}d\;\lambda}}{\int{{L(\lambda)}{S_{r}(\lambda)}d\;\lambda}}},{\rho_{g} = \frac{\int{{L(\lambda)}{\rho(\lambda)}{S_{g}(\lambda)}d\;\lambda}}{\int{{L(\lambda)}{S_{g}(\lambda)}d\;\lambda}}},{\rho_{b} = {\frac{\int{{L(\lambda)}{\rho(\lambda)}{S_{b}(\lambda)}d\;\lambda}}{\int{{L(\lambda)}{S_{b}(\lambda)}d\;\lambda}}.}}}} & (2) \end{matrix}$ Then, R=L _(r)[ρ_(r) h(θ)+β_(s) k(θ)], G=L _(g)[ρ_(g) h(θ)+ρ_(s) k(θ)], B=L _(b)[ρ_(b) h(θ)ρ_(s) k(θ)],  (3) where L_(r), L_(g), and L_(b) are the tristimulus values of the light source. The RGB color space can be re-written in matrix form as:

$\begin{matrix} {\begin{bmatrix} R \\ G \\ B \end{bmatrix} = {{{{h(\theta)}\begin{bmatrix} L_{r} & 0 & 0 \\ 0 & L_{g} & 0 \\ 0 & 0 & L_{b} \end{bmatrix}}\begin{bmatrix} \rho_{r} \\ \rho_{g} \\ \rho_{b} \end{bmatrix}} + {\rho_{s}{{{k(\theta)}\begin{bmatrix} L_{r} \\ L_{g} \\ L_{b} \end{bmatrix}}.}}}} & (4) \end{matrix}$ Let ν₁ and ν₂ be two independent vectors in the RGB space. If the RGB values are projected on plane V spanned by ν₁ and ν₂, the projected coordinates will be:

$\begin{matrix} {{\left\lbrack {v_{1}\mspace{20mu} v_{2}} \right\rbrack^{T}\begin{bmatrix} R \\ G \\ B \end{bmatrix}} = {{{{{h(\theta)}\left\lbrack {v_{1}\mspace{20mu} v_{2}} \right\rbrack}^{T}\begin{bmatrix} L_{r} & 0 & 0 \\ 0 & L_{g} & 0 \\ 0 & 0 & L_{b} \end{bmatrix}}\begin{bmatrix} \rho_{r} \\ \rho_{g} \\ \rho_{b} \end{bmatrix}} + {\rho_{s}{{{{k(\theta)}\left\lbrack {v_{1}\mspace{20mu} v_{2}} \right\rbrack}^{T}\begin{bmatrix} L_{r} \\ L_{g} \\ L_{b} \end{bmatrix}}.}}}} & (5) \end{matrix}$

Let L=[L_(r) L_(g) L_(b)]^(T) be the light source vector. The second term in equation (5) disappears when [ν₁ ν₂]^(T)L=0. It means that when plane V is perpendicular to the light source vector L, the specular component is canceled.

FIG. 2 illustrates an example of projecting the colors of two surfaces on the plane V. According to the NIR model, every color vector of light reflected from a given surface (e.g., S₁) is a linear combination of the specular component (represented by the light source vector L) and the diffuse component (represented by C₁). All the colors of S₁ are on the same plane as L and C₁. Similarly, all the colors of another surface (e.g., S₂) are on the same plane as L and C₂. Therefore, all the colors under the same light source are on the planes that share a common vector L. If all the colors are projected along the light source vector L, their projections will form several lines and those lines intersect at one point which is the projected point of the light source vector. If the projection direction is not along the light source vector L (i.e., if V is not perpendicular to L), then the specular component is not canceled. In this case, the projected colors will no longer form lines on plane V, but instead will spread out over two-dimensional area of plane V. This two-dimensional area, referred to as the projected area on Plane V, can be calculated when ν₁ and ν₂ are orthonormal. Plane V varies when ν₁ and ν₂ change. By changing ν₁ and ν₂, the projected area will become the smallest when plane V is perpendicular to the light source vector L. It does not matter which specific ν₁ and ν₂ are used as the basis vectors, as all of them produce substantially the same results.

In the AWB calculations, the light source vector L for the ground truth light source is unknown. The MPA method varies plane V by choosing different candidate illuminants. From the chosen light source vector L=(L_(r), L_(g), L_(b)) of the candidate illuminant, the orthonormal basis vectors ν₁ and ν₂ can be computed, and a given image's projected area on the plane spanned by ν₁ and ν₂ can also be computed. The projected area is the smallest when the chosen light source vector L is the closest to the ground truth light source of the image.

In one embodiment, the orthonormal basis vectors may be parameterized as follows:

$\begin{matrix} {{{v_{1}\left( {\alpha,\beta} \right)} = {\frac{1}{\sqrt{\alpha^{2} + 1}}\left\lbrack {\alpha\mspace{20mu} - {1\mspace{20mu} 0}} \right\rbrack}^{T}},} & (6) \\ {{v_{2}\left( {\alpha,\beta} \right)} = {{\frac{1}{\sqrt{\alpha^{2} + \alpha^{4} + {\beta^{2}\left( {\alpha^{2} + 1} \right)}^{2}}}\left\lbrack {{- \alpha}\mspace{20mu} - {\alpha^{2}\mspace{20mu}{\beta\left( {\alpha^{2} + 1} \right)}}} \right\rbrack}^{T}.}} & (7) \end{matrix}$ When α=L_(g)/L_(r) and β=L_(g)/L_(b), plane V(α, β) is perpendicular to L.

In one embodiment, the search range for the light sources is narrowed to a subspace where light sources are more likely to occur, since searching through all possible planes V(α, β) is very time consuming. Narrowing the search range also has the benefit of reducing the possibility of finding the wrong light source. In one embodiment, the search range can be a set of illuminants commonly occurred in consumer images of the intended application domain. The term “consumer images” refers to color images that are typically seen on image display devices used by content consumers. Alternatively or additionally, a suitable blending of the daylight locus and the blackbody radiator locus may be used. This blending can provide a light locus covering most illuminants in the consumer images. To search for the light source of an image, the MPA method calculates the image's projected area for each candidate illuminant in a set of candidate illuminants along the light locus. The candidate illuminant that produces the minimum projected area is the best estimate of the scene illuminant (i.e., the ground truth light source), and the image is white balanced according to that scene illuminant. In one embodiment, the MPA method minimizes the following expression:

$\begin{matrix} {{\arg\mspace{11mu}{\min\limits_{\alpha,\beta}\mspace{14mu}{{w\left( {\alpha,\beta} \right)}{Area}\;\left( {\alpha,\beta} \right)}}},} & (8) \end{matrix}$

where w(α, β) is a bias function, and Area(α, β) is the projected area on plane V(α, β), which is spanned by ν₁(α, β) and ν₂ (α, β). The bias function may be used to modify a projected area and thus improve the performance of the MPA method. The bias function relies on the gross scene illuminant distribution, but not the scene content. Therefore, the same bias function can work for any camera model after the camera is calibrated. Details of the bias function w(α, β) will be provided later. In alternative embodiments, the bias function may be omitted (i.e., set to one).

FIG. 3 illustrates an AWB module 300 for performing the MPA method according to one embodiment. The AWB module 300 is an example of the AWB module 110 of FIG. 1A. The AWB module 300 includes a pre-processing unit 310, which processes raw RGB data of an input image to remove over-exposed, under-exposed and saturated pixels. The removal of these pixels can speed up AWB computation and reduce noise. In one embodiment, a pixel is deemed over-exposed and removed if one or more of its R value, G value and B value is within a predetermined vicinity from the maximum of that pixel's color data range; in other words, when one or more of the pixel's color channels is greater than a threshold. After these pixels are removed, the pre-processing unit 310 may group-average the input image by dividing the image into multiple groups of neighboring pixels, and calculating a weighted average of the tricolor values of the neighboring pixels in each group. The weight for each group may be one or another number. In one embodiment, after the calculating the group average, the pre-processing unit 310 may remove under-exposed pixels from the image. A pixel is over-exposed if the sum of its R value, G value and B value is above a first threshold; a pixel is under-exposed if the sum of its R value, G value and B value is below a second threshold. The pre-processing unit 310 may also remove saturated pixels from the image. A pixel is saturated if one of its R value, G value and B value is below a predetermined threshold.

In one embodiment, after the pixel removal and group averaging operations, the pre-processing unit 310 may sub-sample the image to produce a pre-processed image. The pre-processed image is fed into an MPA calculator 380 in the AWB module 300 for MPA calculations.

In one embodiment, the MPA calculator 380 includes a projection plane calculator 320 and a projected area calculator 330. The projection plane calculator 320 calculates two orthonormal vectors ν₁ and ν₂ that span a plane perpendicular to a light source vector (L_(r), L_(g), L_(b)) of a candidate illuminant. In one embodiment, the projection plane calculator 320 calculates ν₁ and ν₂ according to equations (6) and (7), where α and β are given or calculated from a candidate illuminant.

After the projection plane is determined, the projected area calculator 330 projects the RGB values of each pixel in the pre-processed image to that projection plane. The result of the projection is a collection of points that fall onto the projection plane. If each color is represented as an ideal point, then the result of the projection will produce a set of scattered dots on the projected plane, as shown in the examples of FIGS. 4A, 4B and 4C, each of which illustrates a projection result using a different candidate illuminant. The local dot density becomes higher when the projection is along the ground truth light source vector. However, computing dot density requires a large amount of computations. In one embodiment, the projection plane is divided into a set of spatial bins (e.g., squares). A square is counted when one or more pixels are projected into that square. The total number of counted squares may be used as an estimate of the projected area.

Referring to FIGS. 4A, 4B and 4C, in each example, the ‘x’ marks represent the projection points of all pixels of the image. When the candidate illuminant is closer to the ground truth, the total projected area marked by ‘x’s becomes smaller. Each example uses a different candidate illuminant described by the orthonormal bases ν₁ and ν₂. The candidate illuminant that produces the minimum projected area of 119 in FIG. 4B has the smallest area, and is therefore the closest to the ground truth among the three candidate illuminants.

Referring again to FIG. 3, after the projected area calculator 330 calculates the projected areas for a set of different candidate illuminants, a comparator 340 compares the projected areas and identifies a candidate illuminant that produces the minimum projected area. In one embodiment, as an option to improve the AWB results, the comparator 340 may multiply each projected area with the aforementioned bias function, shown herein as a bias value 345 (i.e., a weight), before the comparison. The bias values 345 may be determined based on prior knowledge about how frequently an illuminant along the light locus may occur in consumer images. That is, the bias values 345 represent the prior knowledge of scene illuminant distribution, and are not related to scene contents. In one embodiment, each candidate illuminant is associated with a bias value, which may be denoted as a function w(α, β), where α and β are color ratios of the candidate illuminant. The bias values are stable from one camera model to another camera model.

After the comparator 340 identifies a candidate illuminant that produces the minimum projected area, a gain adjustment unit 350 adjusts the color gain of the input image according to the color ratios α and β of the candidate illuminant.

For an image with multiple different colored objects, the projected area is often minimized when the projection is along the light source vector. However, for images of a single dominant color, the minimum projected area can occur when either the specular component or the diffuse component of the dominant color is canceled. In order to better handle such images of few colors, the search is constrained to the minimum projected area caused by the cancellation of the specular component, not by the diffuse component of the dominant color. One way is to search for the candidates which are close to where the potential light sources are located in the chromaticity space. Therefore, the minimum projected area is searched along the light locus which goes through the population of the known light sources.

In one embodiment, a chromaticity coordinate system (p, q) may be used to parameterize the distribution of light locus in the chromaticity domain with reduced distortion. The coordinate system (p, q) is defined as:

$\begin{matrix} {{p = {{\frac{1}{\sqrt{2}}r} - {\frac{1}{\sqrt{2}}b}}},{q = {{{- \frac{1}{\sqrt{6}}}r} + {\frac{2}{\sqrt{g}}g} - {\frac{1}{\sqrt{6}}b}}},} & (9) \end{matrix}$ where r=R/(R+G+B), g=G/(R+G+B), and b=B/(R+G+B).

For a candidate illuminant (L_(r), L_(g), L_(b)), its (p, q) coordinates can be determined by replacing R, G, B values in equations (9) with the L_(r), L_(g), L_(b) values.

A light locus may be obtained by fitting the color data taken by a reference camera under different illuminants. For example, a curve fitting from three types of light sources: shade, daylight, and tungsten can provide a very good light locus. In one embodiment, a given light locus may be represented by a second-order polynomial function in the (p, q) domain having the form of: q=a ₁ p ² +a ₂ p+a ₃.  (10)

Given (p, q), the following equations calculate (r, g, b):

$\begin{matrix} {{r = {{\frac{1}{\sqrt{2}}p} - {\frac{1}{\sqrt{6}}q} + \frac{1}{3}}},{g = {{\frac{\sqrt{6}}{3}q} + \frac{1}{3}}},{b = {{{- \frac{1}{\sqrt{2}}}p} - {\frac{1}{\sqrt{6}}q} + {\frac{1}{3}.}}}} & (11) \end{matrix}$

The color ratios α and β can be obtained by:

$\begin{matrix} {{\alpha = \frac{g}{r}},{\beta = {\frac{g}{b}.}}} & (12) \end{matrix}$

Accordingly, given a (p, q) along the light locus, the color ratios α and β can be computed. Using equations (6) and (7), the orthonormal vectors ν₁(α, β) and ν₂ (α, β) can be computed, and the projected area of an image on plane V spanned by ν₁(α, β) and ν₂ (α, β) can also be computed.

When a scene is illuminated by a single dominant light source, the MPA method can estimate the light source accurately. However, some scenes have more than one light source. In one embodiment, a block MPA method is used to handle such multiple-illuminant scenarios. With the block MPA method, an image is divided into several blocks and the MPA method is applied to each block.

FIG. 5 illustrates an AWB module 500 for performing the block MPA method according to one embodiment. The AWB module 500 is an example of the AWB module 110 of FIG. 1A. The AWB module 500 includes a pre-processing unit 510, which further includes a block dividing unit 515 to divide an input image into multiple blocks. The pre-processing unit 510 performs the same pixel removal operations as the pre-processing unit 310 of FIG. 3 on each block to remove over-exposed, under-exposed and saturated pixels. The pre-processing unit 510 also determines whether each block has a sufficient number of pixels (e.g., 10 pixels) for the MPA method after the pixel removal operations. If less than a threshold number of blocks (e.g., half of the number of blocks) have sufficient number of pixels for the MPA method, the pre-processing unit 510 re-divides the image into fewer number of blocks, such that the number of new blocks in the image is greater than the threshold number.

In one embodiment, the AWB module 500 includes one or more MPA calculators 310 to execute the MPA method on each block. The per-block results are gathered by an weighted averaging unit 540, which averages the chromaticity coordinate p first, then finds the other chromaticity coordinate q based on the fitted curve (e.g., the second-order polynomial function in (10)) for a given light locus. In one embodiment, the weighted averaging unit 540 applies a weight to each block; for example, the weight of a block having the main object may be higher than other blocks. In alternative embodiment, the weighted averaging unit 540 may apply the same weight to all blocks. The output of the weighted averaging unit 540 is a resulting candidate illuminant or a representation thereof. The gain adjustment unit 350 then adjusts the color gain of the input image using the color ratios α and β of the resulting candidate illuminant.

FIG. 6 is a flow diagram illustrating a MPA method 600 performed on a color image according to one embodiment. The MPA method 600 may be performed by a device, such as the device 150 of FIG. 1B; more specifically, the MPA method 600 may be performed by the AWB module 110 of FIG. 1A, the AWB module 300 of FIG. 3 and/or the AWB module 500 of FIG. 5.

The MPA method 600 begins with a device pre-processing an image to obtain pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value (step 610). For each candidate illuminant in a set of candidate illuminants, the device performs the following operations: calculating a projection plane perpendicular to a vector that represents tricolor values of the candidate illuminant (step 620), and projecting the tricolor values of each of the pre-processed pixels to the calculated projection plane to obtain a projected area (step 630). One of the candidate illuminants is identified as a resulting illuminant for which the projected area is the minimum projected area among the candidate illuminants (step 640). The device may use the color ratios of the resulting illuminant to adjust the color gains of the image.

According to another embodiment, AWB may be performed using the MTV method, which is also based on the same principle as the MPA method by seeking to cancel the specular component. According to the NIR model, a pair of chroma images, (αC₁−C₂) and (βC₃−C₂), can be created from a given image by scaling one color channel and taking the difference with another color channel. (C₁, C₂, C₃) is the linear transformation of tricolor values (R,G,B).

$\begin{matrix} {\begin{bmatrix} C_{1} \\ C_{2} \\ C_{3} \end{bmatrix} = {\begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{bmatrix}\begin{bmatrix} R \\ G \\ B \end{bmatrix}}} & (13) \end{matrix}$

Both (αC₁−C₂) and (βC₃−C₂) are functions of spatial locations in the image. The two chroma images can be expressed as:

$\begin{matrix} {\left( {{\alpha\; C_{1}} - C_{2}} \right) = {\quad{{\left\lbrack {{\left( {{\alpha\; a_{11}} - a_{21}} \right)L_{r}\rho_{r}} + {\left( {{\alpha\; a_{12}} - a_{22}} \right)L_{g}\rho_{g}} + {\left( {{\alpha\; a_{13}} - a_{23}} \right)L_{b}\rho_{b}}} \right\rbrack{h(\theta)}} + {\quad{{\left\lbrack {{\left( {{\alpha\; a_{11}} - a_{21}} \right)L_{r}} + {\left( {{\alpha\; a_{12}} - a_{22}} \right)L_{g}} + {\left( {{\alpha\; a_{13}} - a_{23}} \right)L_{b}}} \right\rbrack\rho_{s}{k(\theta)}},{\left( {{\beta\; C_{3}} - C_{2}} \right) = {\quad{{\left\lbrack {{\left( {{\beta\; a_{31}} - a_{21}} \right)L_{r}\rho_{r}} + {\left( {{\beta\; a_{32}} - a_{22}} \right)L_{g}\rho_{g}} + {\left( {{\beta\; a_{33}} - a_{23}} \right)L_{b}\rho_{b}}} \right\rbrack{h(\theta)}} + {\quad{\left\lbrack {{\left( {{\beta\; a_{31}} - a_{21}} \right)L_{r}} + {\left( {{\beta\; a_{32}} - a_{22}} \right)L_{g}} + {\left( {{\beta\; a_{33}} - a_{23}} \right)L_{b}}} \right\rbrack\rho_{s}{{k(\theta)}.}}}}}}}}}}} & (14) \end{matrix}$

When α=(a₂₁L_(r)+a₂₂L_(g)+a₂₃L_(b))/(a₁₁L_(r)+a₁₂L_(g)+a₁₃L_(b)) and β=(a₂₁L_(r)+a₂₂L_(g)+a₂₃L_(b))/(a₃₁L_(r)+a₃₂L_(g)+a₃₃L_(b)): (αC ₁ −C ₂)=[(αa ₁₁ −a ₂₁)L _(r)ρ_(r)+(αa ₁₂ −a ₂₂)L _(g)ρ_(g)+(αa ₁₃ −a ₂₃)L _(b)ρ_(b)]h(θ), (βC ₃ −C ₂)=[(βa ₃₁ −a ₂₁)L _(r)ρ_(r)+(βa ₃₂ −a ₂₂)L _(g)ρ_(g)+(βa ₃₃ −a ₂₃)L _(b)ρ_(b)]h(θ).  (15)

The specular component is canceled for both αC₁−C₂ and βC₃−C₂. When the cancellation happens, the total variation of αC₁−C₂ and βC₃−C₂ is greatly reduced because the modulation due to the specular components is gone. There is left only a signal modulation entirely due to the difference in the diffuse components.

By searching along a given light locus, the MTV method finds a candidate illuminant, represented by color ratios α and β, that minimizes the following expression of total variation. The color ratios α and β may be computed from a given point (p, q) on a given light locus using equations (11) and (12). The total variation in this embodiment can be expressed as a sum of absolute gradient magnitudes of the two chroma images in (14):

$\begin{matrix} {{\arg\;{\min\limits_{\alpha,\beta}{\sum_{n}{{\nabla\left( {{\alpha\;{C_{1}(n)}} - {C_{2}(n)}} \right)}}}}} + {{{\nabla\left( {{\beta\;{C_{3}(n)}} - {C_{2}(n)}} \right)}}.}} & (16) \end{matrix}$

It is noted that the gradient of a two-dimensional image is a vector that has an x-component and a y-component. For computational efficiency, a simplified one-dimensional approximation of total variation can be used:

$\begin{matrix} {{\arg\;{\min\limits_{\alpha,\beta}{\sum_{n}{{{\alpha\left\lbrack {{C_{1}(n)} - {C_{1}\left( {n + 1} \right)}} \right\rbrack} - \left\lbrack {{C_{2}(n)} - {C_{2}\left( {n + 1} \right)}} \right\rbrack}}}}} + {{{\beta\left\lbrack {{C_{3}(n)} - {C_{3}\left( {n + 1} \right)}} \right\rbrack} - \left\lbrack {{C_{2}(n)} - {C_{2}\left( {n + 1} \right)}} \right\rbrack}}} & (17) \end{matrix}$

In one embodiment, if any neighboring pixel has been removed due to over-exposure, under-exposure, or color saturation, the gradient of that pixel is excluded from the total variation calculation.

FIG. 7 illustrates an AWB module 700 for performing the MTV method according to one embodiment. The AWB module 700 is another example of the AWB module 110 of FIG. 1A. The AWB module 700 includes the pre-processing unit 310, which processes raw RGB data of an input image to remove over-exposed, under-exposed and saturated pixels. The AWB module 700 further includes an MTV calculator 780, which searches for a minimum total variation solution in a set of candidate illuminants. More specifically, the MTV calculator 780 further includes a difference calculator 720 and a comparator 730. The difference calculator 720 calculates the total variation for each candidate illuminant, and the comparator 730 compares the results from the difference calculator 720 to identify a minimum total variation. In one embodiment, the comparator 730 may multiply each total variation with a bias value 345 (i.e., a weight) before the comparison. The bias values 345 may be determined based on prior knowledge about how frequently an illuminant along the light locus may occur in consumer images. That is, the bias values 345 represent the prior knowledge of scene illuminant distribution, and are not related to scene contents. In one embodiment, each candidate illuminant is associated with a bias value, which may be denoted as a function w(α, β), where α and β are color ratios of the candidate illuminant The bias values are stable from one camera model to another camera model.

After the comparator 730 identifies the candidate illuminant that produces the minimum total variation, the gain adjustment unit 350 adjusts the color gain of the input image using the color ratios α and β of the candidate illuminant. Experiment results show that the MTV method performs well for a single dominant illuminant as well as multiple illuminants.

FIG. 8 is a flow diagram illustrating a MTV method 800 performed on a color image according to an alternative embodiment. In this alternative embodiment, a linear transformation is applied to the tricolor values in the calculation of the total variation. The MTV method 800 may be performed by a device, such as the device 150 of FIG. 1B; more specifically, the MTV method 800 may be performed by the AWB module 110 of FIG. 1A and/or the AWB module 700 of FIG. 7.

The MTV method 800 begins with a device pre-processing an image to obtain a plurality of pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value (step 810). For each candidate illuminant in a set of candidate illuminants, the device calculates a total variation in the tricolor values between neighboring pixels of the pre-processed pixels (step 820). The calculation of the total variation includes the operations of: calculating a linear transformation of the tricolor values to obtain three transformed values (step 830); calculating a first scaling factor and a second scaling factor, which represent two color ratios of the candidate illuminant (step 840); constructing a first chroma image by taking a difference between a first transformed value scaled by the first scaling factor and a second transformed value (step 850); constructing a second chroma image by taking a difference between a third transformed value scaled by the second scaling factor and the second transformed value (step 860); and calculating an indicator value by summing absolute gradient magnitudes of the first chroma image and absolute gradient magnitudes of the second chroma image (step 870). After the total variations of all candidate illuminants are computed, the device selects a candidate illuminant for which the total variation is the minimum among all of total variations (step 880).

FIG. 9 is a flow diagram illustrating a method 900 for performing automatic white balance on an image according to one embodiment. The method 900 may be performed by a device, such as the device 150 of FIG. 1B; more specifically, the method 900 may be performed by the AWB module 110 of FIG. 1A, the AWB module 300 of FIG. 3, the AWB module 500 of FIG. 5, and/or the AWB module 700 of FIG. 7.

The method 900 begins with a device pre-processing the image to obtain a plurality of pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value (step 910). For each candidate illuminant in a set of candidate illuminants, the device calculates an indicator value that has a diffuse component and a specular component (step 920). The device then identifies one of the candidate illuminants as a resulting illuminant for which the indicator value is a minimum indicator value among the candidate illuminants, wherein the minimum indicator value corresponds to cancellation of the specular component (step 930). According to color ratios derived from the resulting illuminant, the device adjusts color gains of the image (step 940). In one embodiment, the indicator value is a projected area as described in connection with the MPA method 600 in FIG. 6; in alternative embodiments, the indicator value is a total variation as described in connection with the MTV method 800 in FIG. 8.

The operations of the flow diagrams of FIGS. 6, 8 and 9 have been described with reference to the exemplary embodiments of FIGS. 1A, 1B, 3, 5 and 7. However, it should be understood that the operations of the flow diagrams of FIGS. 6, 8 and 9 can be performed by embodiments of the invention other than the embodiments discussed with reference to FIGS. 1A, 1B, 3, 5 and 7, and the embodiments discussed with reference to FIGS. 1A, 1B, 3, 5 and 7 can perform operations different than those discussed with reference to the flow diagrams. While the flow diagrams of FIGS. 6, 8 and 9 show a particular order of operations performed by certain embodiments of the invention, it should be understood that such order is exemplary (e.g., alternative embodiments may perform the operations in a different order, combine certain operations, overlap certain operations, etc.).

Various functional components or blocks have been described herein. As will be appreciated by persons skilled in the art, the functional blocks will preferably be implemented through circuits (either dedicated circuits, or general purpose circuits, which operate under the control of one or more processors and coded instructions), which will typically comprise transistors that are configured in such a way as to control the operation of the circuitry in accordance with the functions and operations described herein.

While the invention has been described in terms of several embodiments, those skilled in the art will recognize that the invention is not limited to the embodiments described, and can be practiced with modification and alteration within the spirit and scope of the appended claims. The description is thus to be regarded as illustrative instead of limiting. 

What is claimed is:
 1. A method for performing automatic white balance on an image, comprising: pre-processing the image to obtain a plurality of pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value; calculating, for each candidate illuminant in a set of candidate illuminants, an indicator value that has a diffuse component and a specular component; identifying one of the candidate illuminants as a resulting illuminant for which the indicator value is a minimum indicator value among the candidate illuminants, wherein the minimum indicator value corresponds to cancellation of the specular component; and adjusting color gains of the image according to color ratios derived from the resulting illuminant.
 2. The method of claim 1, wherein calculating the indicator value for each candidate illuminant further comprises: calculating a projection plane perpendicular to a vector that represents tricolor values of the candidate illuminant; and projecting the tricolor values of each of the pre-processed pixels to the calculated projection plane to obtain a projected area as the indicator value.
 3. The method of claim 2, further comprising: dividing the image into multiple blocks; identifying, for each block, a corresponding resulting illuminant; and calculating the resulting illuminant based on all of corresponding resulting illuminants identified for the multiple blocks.
 4. The method of claim 3, wherein the resulting illuminant is a weighted average of all of the corresponding resulting illuminants, or one of the corresponding resulting illuminants as a result of voting.
 5. The method of claim 1, wherein the set of candidate illuminants are represented in a chromaticity space by a plurality of points that lie on a light locus generated from a population of known illuminants in an image database, or from a blending of loci that include at least a daylight locus and a blackbody radiator locus.
 6. The method of claim 1, further comprising: for each illuminant candidate, weighting the indicator value by a bias value associated with the illuminant candidate, wherein the bias value indicates a likelihood of the illuminant candidate being a true illuminant for the image.
 7. The method of claim 1, wherein pre-processing the image further comprises: dividing the image into a plurality of groups of neighboring pixels; and calculating a weighted average of the tricolor values of the neighboring pixels in each group.
 8. The method of claim 1, wherein pre-processing the image further comprises: removing pixels in the image that are over-exposed, under-exposed or saturated.
 9. The method of claim 8, wherein removing the pixels further comprises: removing a pixel if one or more of following conditions are true: one of the R value, the G value and the B value of the pixel is within a predetermined vicinity from a maximum of a color data range of the pixel; a sum of the R value, the G value and the B value of the pixel is above a first threshold or below a second threshold; and one of the R value, the G value and the B value of the pixel is below a third threshold.
 10. The method of claim 1, wherein calculating the indicator value for each candidate illuminant further comprises: calculating a total variation in the tricolor values between neighboring pixels of the pre-processed pixels as the indicator value, wherein calculating the total variation further comprises: calculating a linear transformation of the tricolor values to obtain three transformed values; calculating a first scaling factor and a second scaling factor, which represent two color ratios of the candidate illuminant; constructing a first chroma image by taking a difference between a first transformed value scaled by the first scaling factor and a second transformed value; constructing a second chroma image by taking a difference between a third transformed value scaled by the second scaling factor and the second transformed value; and calculating the total variation by summing absolute gradient magnitudes of the first chroma image and absolute gradient magnitudes of the second chroma image.
 11. A device for performing automatic white balance on an image, comprising: a memory to store the image; an image processing circuitry, which is coupled to the memory and is operative to: pre-process the image to obtain a plurality of pre-processed pixels, each of which represented by tricolor values that include a red (R) value, a green (G) value and a blue (B) value; calculate, for each candidate illuminant in a set of candidate illuminants, an indicator value that has a diffuse component and a specular component; identify one of the candidate illuminants as a resulting illuminant for which the indicator value is a minimum indicator value among the candidate illuminants, wherein the minimum indicator value corresponds to cancellation of the specular component; and adjust color gains of the image according to color ratios derived from the resulting illuminant; and a display coupled to the image processing circuitry to display the image with the adjusted color gains.
 12. The device of claim 11, wherein the image processing circuitry, when calculating the indicator value for each candidate illuminant, is further operative to: calculate a projection plane perpendicular to a vector that represents tricolor values of the candidate illuminant; and project the tricolor values of each of the pre-processed pixels to the calculated projection plane to obtain a projected area as the indicator value.
 13. The device of claim 12, wherein the image processing circuitry is further operative to: divide the image into multiple blocks; identify, for each block, a corresponding resulting illuminant; and calculate the resulting illuminant based on all of corresponding resulting illuminants identified for the multiple blocks.
 14. The device of claim 13, wherein the resulting illuminant is a weighted average of all of the corresponding resulting illuminants, or one of the corresponding resulting illuminants as a result of voting.
 15. The device of claim 11, wherein the set of candidate illuminants are represented in a chromaticity space by a plurality of points that lie on a light locus generated from a population of known illuminants in an image database, or from a blending of loci that include at least a daylight locus and a blackbody radiator locus.
 16. The device of claim 11, wherein the image processing circuitry is further operative to: for each illuminant candidate, weight the indicator value by a bias value associated with the illuminant candidate, wherein the bias value indicates a likelihood of the illuminant candidate being a true illuminant for the image.
 17. The device of claim 11, wherein the image processing circuitry, when pre-processing the image, is further operative to: divide the image into a plurality of groups of neighboring pixels; and calculate a weighted average of the tricolor values of the neighboring pixels in each group.
 18. The device of claim 11, wherein the image processing circuitry, when pre-processing the image, is further operative to: remove pixels in the image that are over-exposed, under-exposed or saturated.
 19. The device of claim 18, wherein the image processing circuitry is further operative to: remove a pixel if one or more of following conditions are true: one of the R value, the G value and the B value of the pixel is within a predetermined vicinity from a maximum of a color data range of the pixel; a sum of the R value, the G value and the B value of the pixel is above a first threshold or below a second threshold; and one of the R value, the G value and the B value of the pixel is below a third threshold.
 20. The device of claim 11, wherein the image processing circuitry, when calculating the indicator value for each candidate illuminant, is further operative to: calculate a total variation in the tricolor values between neighboring pixels of the processed pixels as the indicator value, wherein the image processing circuitry, when calculating the total variation, is further operative to: calculate a linear transformation of the tricolor values to obtain three transformed values; calculate a first scaling factor and a second scaling factor, which represent two color ratios of the candidate illuminant; construct a first chroma image by taking a difference between a first transformed value scaled by the first scaling factor and a second transformed value; construct a second chroma image by taking a difference between a third transformed value scaled by the second scaling factor and the second transformed value; and calculate the indicator value by summing absolute gradient magnitudes of the first chroma image and absolute gradient magnitudes of the second chroma image. 